Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@httptoolkit/httpolyglot
Advanced tools
Serve http and https connections over the same port with node.js
Part of HTTP Toolkit: powerful tools for building, testing & debugging HTTP(S)
A module for serving HTTP, HTTPS and HTTP/2 connections, all over the same port.
Forked from the original httpolyglot
to fix various issues required for HTTP Toolkit, including:
tlsClientError
: https://github.com/mscdex/httpolyglot/pull/11clientError
events (https://github.com/mscdex/httpolyglot/issues/13)server.on(x, ...)
to hear about x
from all internal servers - HTTP/2, HTTP/1, TLS and net)npm install @httptoolkit/httpolyglot
const httpolyglot = require('@httptoolkit/httpolyglot');
const fs = require('fs');
httpolyglot.createServer({
key: fs.readFileSync('server.key'),
cert: fs.readFileSync('server.crt')
}, function(req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end((req.socket.encrypted ? 'HTTPS' : 'HTTP') + ' Connection!');
}).listen(9000, 'localhost', function() {
console.log('httpolyglot server listening on port 9000');
// visit http://localhost:9000 and https://localhost:9000 in your browser ...
});
const httpolyglot = require('@httptoolkit/httpolyglot');
const fs = require('fs');
httpolyglot.createServer({
key: fs.readFileSync('server.key'),
cert: fs.readFileSync('server.crt')
}, function(req, res) {
if (!req.socket.encrypted) {
res.writeHead(301, { 'Location': 'https://localhost:9000' });
return res.end();
}
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Welcome, HTTPS user!');
}).listen(9000, 'localhost', function() {
console.log('httpolyglot server listening on port 9000');
// visit http://localhost:9000 and https://localhost:9000 in your browser ...
});
Server - A class similar to https.Server (except instances have setTimeout()
from http.Server).
createServer(< object >tlsConfig[, < function >requestListener]) - Server - Creates and returns a new Server instance.
TLS and HTTP connections are easy to distinguish based on the first byte sent by clients trying to connect. See this comment for more information.
FAQs
Serve http and https connections over the same port with node.js
The npm package @httptoolkit/httpolyglot receives a total of 56,655 weekly downloads. As such, @httptoolkit/httpolyglot popularity was classified as popular.
We found that @httptoolkit/httpolyglot demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.